Skip to content

Persist per-issue token usage#60

Open
danielmcauley wants to merge 1 commit into
mainfrom
codex/persist-token-usage-ledger
Open

Persist per-issue token usage#60
danielmcauley wants to merge 1 commit into
mainfrom
codex/persist-token-usage-ledger

Conversation

@danielmcauley
Copy link
Copy Markdown

@danielmcauley danielmcauley commented Apr 21, 2026

Context

Symphony shows live token totals, but completed tickets lose per-issue token observability after the run exits or the process restarts.

TL;DR

Persist per-issue Codex token totals in a JSONL ledger.

Summary

  • Add a durable token usage ledger next to Symphony logs.
  • Record live and final high-water token observations per issue/session.
  • Expose ledger summaries in the observability API.
  • Document durable token accounting and API behavior.

Alternatives

  • SQLite was considered, but JSONL fits the existing logs-root model.
  • Linear comments were avoided because they are a display surface, not a ledger.

Test Plan

  • mise exec -- make all
  • mise exec -- mix test test/symphony_elixir/token_usage_ledger_test.exs test/symphony_elixir/orchestrator_status_test.exs test/symphony_elixir/extensions_test.exs
  • mise exec -- mix specs.check

jimoosciuc

This comment was marked as low quality.

jimoosciuc

This comment was marked as low quality.

Copy link
Copy Markdown

@gpt-cmdr gpt-cmdr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM — dual-approved, merging.

chihsuan referenced this pull request in Automattic/symphony May 15, 2026
@REFaster
Copy link
Copy Markdown

BLOCKED-OPERATOR: clean MERGEABLE PR with green checks and approvals, but an active human review request remains for frantic-openai. Auto-merge is blocked until that request is cleared or the operator explicitly owns the merge.

@REFaster
Copy link
Copy Markdown

BLOCKED-REBASE: this PR is now DIRTY against main. Visible checks are green (make-all, validate-pr-description), but automation cannot merge until the branch is clean; the active human review request for frantic-openai also still blocks auto-merge after rebase.

corylanou added a commit to digitaldrywood/symphony that referenced this pull request May 21, 2026
#### Context

Fixes #22. Symphony token and runtime stats reset on restart, which hides cumulative usage and completed-session history.

#### TL;DR

*Persist run and Codex session stats in SQLite and show lifetime totals.*

#### Summary

- Add a SQLite-backed stats facade for Symphony runs and Codex sessions.
- Persist run aggregates, completed sessions, shutdown snapshots, and model names.
- Add lifetime totals and recent sessions to `/api/v1/state` and the dashboard.
- Document the durable stats database and API fields.

#### Alternatives

- Upstream openai#60 uses JSONL; this keeps SQLite to match the issue storage acceptance.
- Used additive `/api/v1/state` fields instead of adding another endpoint.

#### Test Plan

- [x] `make -C elixir all`
- [x] `mix test test/symphony_elixir/stats_test.exs test/symphony_elixir/orchestrator_status_test.exs test/symphony_elixir/extensions_test.exs`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants